﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Blog.Contracts;
using Blog.ThirdPartyCallLogs.Enums;

namespace Blog.ThirdPartyCallLogs
{
    [Table("SysThirdPartySystemCallLogs")]
    public class ThirdPartySystemCallLog : CreationAuditedEntity<Guid>, IMustHaveTenant
    {
        public const int MaxCodeLength = 64;
        public const int MaxRequestParametersLength = 4096;
        public const int MaxResponseDataLength = 4096;
        public const int MaxErrorInfoLength = 4096;
        public const int MaxMethodNameLength = 256;
        public const int MaxServiceNameLength = 256;
        public const int MaxClassFullNameLength = 256;
        public const int MaxInputParamClassFullNameLength = 256;

        public int TenantId { get; set; }

        /// <summary>
        /// 业务表主键
        /// </summary>
        public Guid? NatrualKeyId { get; set; }

        /// <summary>
        /// 来源系统（数据字典）
        /// </summary>
        [StringLength(MaxCodeLength)]
        public string SourceSystem { get; set; }

        //请求时间==创建时间

        //请求用户==创建用户；

        /// <summary>
        /// 请求参数（json)
        /// </summary>
        //[StringLength(MaxRequestParametersLength)]
        public string RequestParameters { get; set; }

        /// <summary>
        /// 响应数据（json）
        /// </summary>
        //[StringLength(MaxResponseDataLength)]
        public string ResponseData { get; set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        //[StringLength(MaxErrorInfoLength)]
        public string ErrorInfo { get; set; }

        /// <summary>
        /// 服务名
        /// </summary>
        [StringLength(MaxServiceNameLength)]
        public string ServiceName { get; set; }
        
        /// <summary>
        /// 全限定名-方便用于反射获取对象
        /// </summary>
        [StringLength(MaxClassFullNameLength)]
        public string ClassFullName { get; set; }
        
        /// <summary>
        /// 我方主动调用第三方接口时，传入参数类名全限定名
        /// </summary>
        [StringLength(MaxInputParamClassFullNameLength)]
        public string InputParamClassFullName { get; set; }

        /// <summary>
        /// 方法名
        /// </summary>
        [StringLength(MaxMethodNameLength)]
        public string MethodName { get; set; }

        /// <summary>
        /// 接口调用是否成功
        /// </summary>
        public bool IsSuccess { get; set; }

        /// <summary>
        /// 调用类型
        /// </summary>
        public ThridPartyCallType ThridPartyCallType { get; set; }

    }
}